#from django.contrib.gis.db import models
from django.db import models

class SiteSummary(models.Model):
    name = models.CharField(max_length=200)
    placemark = models.CharField(max_length=200)
    museum_code = models.CharField(max_length=20, blank=True)
    description = models.CharField(max_length=500, blank=True)
    longitude = models.FloatField()
    latitude = models.FloatField()
#    location = models.PointField()
    
#    objects = models.GeoManager()
    
    def __unicode__(self):
        return self.name
    
    class Meta:
        verbose_name_plural = 'Site summaries'
 
class SiteDig(models.Model):
    summary = models.ForeignKey(SiteSummary)
#    description = models.TextField(blank=True)
    description = models.TextField(max_length=5000,blank=True)
    
class BusRoute(models.Model):
    route_num = models.SlugField(max_length=30, unique=True)
    
#    objects = models.GeoManager()
    
    def __unicode__(self):
        return self.route_num

class BusStop(models.Model):
    number = models.SlugField(max_length=10, unique=True)
    sitename = models.SlugField()
    feature_location = models.SlugField(max_length=200)
    town_name = models.SlugField(blank=True)
    locality_name = models.SlugField(blank=True)
    area_code = models.SlugField(max_length=3)
    easting = models.FloatField()
    westing = models.FloatField()
#    location = models.PointField(blank=True, null=True)
    bus_route = models.ManyToManyField(BusRoute, through='BusStopRoute', related_name='route_busstops')
    
#    objects = models.GeoManager()
    
    def __unicode__(self):
        from django.utils.text import recapitalise
        return recapitalise(self.sitename)
    
class BusStopRoute(models.Model):
    bus_stop = models.ForeignKey(BusStop)
    bus_route = models.ForeignKey(BusRoute)
    run_num = models.FloatField()
    sequence_num = models.FloatField()
    
    
    

